package cn.sys.controller;

import cn.sys.service.LogService;
import cn.sys.utils.DataGridView;
import cn.sys.utils.ResultObj;
import cn.sys.vo.LogVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 日志管理控制器类
 * @author Mxb
 * @version 1.0
 * @date 2019/11/1 9:23
 */
@RestController
@RequestMapping("log")
public class LogController {

    @Autowired
    private LogService logService;

    //加载所有日志
    @RequestMapping("loadAllLogInfo")
    public DataGridView loadAllLogInfo(LogVo logVo) {
        return this.logService.queryAllLoginInfo(logVo);
    }

    //删除日志
    @RequestMapping("deleteLog")
    public ResultObj deleteLog(LogVo logVo) {
        try {
            this.logService.deleteLogInfo(logVo.getId());
            return ResultObj.DELETE_SUCCESS;
        } catch (Exception e) {
            e.printStackTrace();
            return ResultObj.DELETE_ERROR;
        }
    }

    //批量删除
    @RequestMapping("deleteBatchLog")
    public ResultObj deleteBatchLog(LogVo logVo) {
        try {
            this.logService.deleteBatchLog(logVo.getIds());
            return ResultObj.DELETE_SUCCESS;
        } catch (Exception e) {
            e.printStackTrace();
            return ResultObj.DELETE_ERROR;
        }
    }
}
